package com.example.service;

import com.example.entity.Pj_details;
import com.example.dao.Pj_detailsDao;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class Pj_detailsService {

    @Resource
    private Pj_detailsDao pj_detailsDao;

    public Pj_details save(Pj_details pj_details) {
        return pj_detailsDao.save(pj_details);
    }

    public void delete(Long id) {
        pj_detailsDao.deleteById(id);
    }

    public Pj_details findById(Long id) {
        return pj_detailsDao.findById(id).orElse(null);    }

    public List<Pj_details> findAll() {
        return pj_detailsDao.findAll();
    }

    public Page<Pj_details> findPage(int pageNum, int pageSize) {
        return pj_detailsDao.findAll(PageRequest.of(pageNum - 1, pageSize));
    }

}